package org.jet.emall.prod.transfer;

import org.jet.emall.prod.dto.OrderDTO;
import org.jet.emall.prod.dto.OrderItemDetailViewDTO;
import org.jet.emall.prod.po.OrderItemDetailView;
import org.jet.emall.prod.po.OrderMaster;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author xiaozai
 * @version 1.0
 * @date 2020-04-25 12:29
 */
@Mapper(imports = {org.jet.emall.common.constant.PaymentType.class,org.jet.emall.common.constant.OrderStatusValue.class})
public interface OrderDtoTransfer {

    OrderDtoTransfer INSTANCE = Mappers.getMapper(OrderDtoTransfer.class);


    /**
     *   将订单PO转DTO
     * @param orderMaster
     * @return
     */
    @Mappings({
            @Mapping(target = "items",ignore = true)
    })
    OrderDTO toDto(OrderMaster orderMaster);

    /**
     *  将订单PO列表转DTO列表
     * @param list
     * @return
     */
    List<OrderDTO> toDtoList(List<OrderMaster> list);


    /**
     *  将订单项PO列表转DTO列表
     * @param views
     * @return
     */
    List<OrderItemDetailViewDTO> toItemDtoList(List<OrderItemDetailView> views);
}
